﻿@using ZBJF.Warranty.Common.Enums.InsuranceOrder
@using ZBJF.Warranty.WebProvider

@{
    ViewBag.Title = "导入保单";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<ul class="nav nav-tabs">
    <li class="active"><a href="javascript:void(0)">导入保单</a></li>
</ul>

@using (Html.BeginForm("ImportInsuranceOrderData", "InsuranceOrder", FormMethod.Post, new { id = "importInsuranceOrderDataForm", name = "importInsuranceOrderDataForm", @class = "breadcrumb form-search", enctype = "multipart/form-data" }))
{

    <table>
        <tr>
            <td>
                <label>选择文件:</label>
            </td>
            <td>
                <span class="showFileName"></span>
                <a href="javascript:void(0)" class="file">
                    选择导入文件
                    <input type="file" name="importFile" validate="{required:true,messages:{required:'请先选择要上传的文件'}}"/>
                </a>
                <input id="btnSubmit" class="btn btn-primary Import-R" type="submit" value="导入保单">
                <a href="/DownLoad/Template/InsuranceTemplate.xlsx">下载导入模版</a>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                
            </td>
        </tr>
    </table>
}
@if (!string.IsNullOrEmpty(ViewBag.ReturnInfo!=null?ViewBag.ReturnInfo.ToString():string.Empty))
{
    <table class="table table-hover table-responsive noborder border-gray">
        <tr class="warning"><td class="w160 text-right">返回结果:</td><td class="w540" colspan="3">@ViewBag.ReturnInfo.Message</td></tr>
    </table>
}
@section scripts{
    <script type="text/javascript">
        $(function() {
            $(".file").on("change", "input[type='file']", function() {
                var filePath = $(this).val();
                if (filePath.indexOf("xls") != -1 || filePath.indexOf("xlsx") != -1) {
                    var arr = filePath.split('\\');
                    var fileName = arr[arr.length - 1];
                    $(".showFileName").html(fileName).removeClass("red");
                } else {
                    $(".showFileName").html("请选择Excel文件").addClass("red");
                    return;
                }
            });
            $("#importInsuranceOrderDataForm").submit(function() {
                if ($(this).valid()) {
                    if ($(".showFileName").hasClass("red")) {
                        layer.alert("请选择Excel文件");
                        return false;
                    }
                    layer.load();
                    return true;
                }
                return false;
            });
        })
    </script>
}
